Javascript - Is it possible to convert a varying-length if-else statement into for loop

welcome to shbcf.ru